<html>
<head>
<script type="text/javascript">
		var aJaxURL	= "server-side/report/cartridge_history.action.php";		//server side folder url   
		var tName	= "report";	
		$(document).ready(function () {  
			GetDate("search_start");
			GetDate("search_end");
			var start	= $("#search_start").val();
	    	var end		= $("#search_end").val();      	
			LoadTable(start,end);	
			loadSum();
								
		});

		
        
		function LoadTable(start, end){
			var total = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
			/* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
			GetDataTableee(tName, aJaxURL, "get_list", 18, "start=" + start + "&end=" + end, 0, "", 1, "desc", total);
			$("#search_code").css("width", "90%");
			$("#search_model").css("width", "90%");
			$("#search_letter").css("width", "80%");
			$("#search_date").css("width", "90%");
			$("#search_type").css("width", "80%");
			SetEvents('','','','report','dialog',aJaxURL);
			
         }

	    $(document).on("change", "#search_start", function () {
	    	var start	= $(this).val();
	    	var end		= $("#search_end").val();
	    	LoadTable(start, end);
	    	loadSum(start, end);
	    	
	    });
	    
	    $(document).on("change", "#search_end", function () {
	    	var start	= $("#search_start").val();
	    	var end		= $(this).val();
	    	LoadTable(start, end);
	    	loadSum(start, end);
	    });

	    function loadSum(){
	
	    	$("#sum_sagarantio").html(($("#sagarantio").html()).split("<br>")[1]);
	    	$("#sum_toneri").html(($("#toneri").html()).split("<br>")[1]);
	    	$("#sum_magnituri").html(($("#magnituri").html()).split("<br>")[1]);
	    	$("#sum_barabani").html(($("#barabani").html()).split("<br>")[1]);
	    	$("#sum_rezini").html(($("#rezini").html()).split("<br>")[1]);
	    	$("#sum_gamwmendi").html(($("#gamwmendi").html()).split("<br>")[1]);
	    	$("#sum_chipi").html(($("#chipi").html()).split("<br>")[1]);
	    	$("#sum_dozirebis").html(($("#dozirebis").html()).split("<br>")[1]);
	    	$("#sum_korpusi").html(($("#korpusi").html()).split("<br>")[1]);
	    	$("#sum_qv").html(($("#report_info").html()).split(" ")[3]);
	    //	$("#price").html(($("#report_info").html()).split(" ")[3]);
	    	$("#sum_price").html(($("#price").html()).split("<br>")[1]);
	    	$("#sum_self_cost").html(($("#self_cost").html()).split("<br>")[1]);
	    	$("#profit").html($("#sum_price").html().replace(" ლ", "")-$("#sum_self_cost").html().replace(" ლ", ""));

	    	
		}
	    function red() {
	    	td = $("table tr td:nth-child(20)");
	    	for (t in td){
		    	if(parseInt($(td[t]).text())<0 & t!='selector'){
		    	$(td[t]).css("color", "rgb(255, 0, 0) !important;");
		    	console.log(t)
		    	console.log($(td[t]))
		    	}}
	    	};
		function LoadDialog(form){
			GetDialog(form);
			    }	    
</script>

</head>

<body>    
    <div id="dt_example" class="ex_highlight_row clear_box">
        <div id="container" style="width:99% !important"> 
            <div id="dynamic">
            
               <table border="1" id="sums_table">
        		<tr>
	        		<td>საგარანტიო</td>
	        		<td id="sum_sagarantio"></td>
	        		<td style="background:none !important; border:none !important;">&nbsp;</td>
	        		<td>სულ.რაოდენობა</td>
	        		<td id="sum_qv"> </td>
	        	</tr>
	        	<tr>
	        		<td>ტონერი</td>
	        		<td  id="sum_toneri"></td>
	        		<td style="background:none !important; border:none !important;">&nbsp; &nbsp;</td>
	        		<td >სულ ფასი</td>
	        		<td id="sum_price"></td>
	        	</tr>
	        	<tr>
	        		<td>ბარაბანი</td>
	        		<td id="sum_barabani"> </td>
	        		<td style="background:none !important; border:none !important;">&nbsp;</td>
	        		<td>თვითღირებულება</td>
	        		<td id="sum_self_cost">ლ</td>
	        	</tr>
	        	<tr>
	        		<td>მაგნ. ლილვი</td>
	        		<td id="sum_magnituri"> </td>
	        		<td style="background:none !important; border:none !important;">&nbsp;</td>
	        		<td>დ. მოგება</td>
	        		<td id="profit">ლ</td>
	        	</tr>
	        	<tr>
	        	<td>გამწმ.რაკელი</td>
	        		<td id="sum_gamwmendi"></td>
	        	</tr>
	           <tr>
	        	<td>დოზ.რაკელი</td>
	        		<td id="sum_dozirebis"></td>
	        	</tr>  
	        	<tr>
	        	<td>ჩიპი</td>
	        		<td id="sum_chipi"> </td>
	        	</tr>
	        	<tr>
	        	<td>კორპუსი</td>
	        		<td id="sum_korpusi"> </td>
	        	</tr>           
			        </table>
            
            	<h2 align="center">კარტრიჯების ისტორია </h2>
            	
            	<div id="button_area">
	            	<div class="left" style="width: 250px;">
	            		<label for="search_start" class="left" style="margin: 5px 0 0 9px;">დასაწყისი</label>
	            		<input type="text" name="search_start" id="search_start" class="inpt right" style="padding: 0px !important; height: 25px !important;"/>
	            	</div>
	            	<div class="right" style="width: 260px;">
	            		<label for="search_end" class="left" style="margin: 5px 0 0 9px;">დასასრული</label>
	            		<input type="text" name="search_end" id="search_end" class="inpt right" style="padding: 0px !important; height: 25px !important;"/>
            		</div>
            	</div>
            	
                <table class="display  center_td" id="report">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th style="width: 80px;">ტიპი</th>  
                            <th style="width: 125px;">შტრიხკოდი</th>   
                            <th style="width: 110px;">მოდელი</th>                                                                           
                            <th style="width: 70px;">ბარათი</th>
                            <th style="width: 136px;" title="შეფუთვის თარიღი">შეფუთვის თარიღი</th>                            
                            <th style="width: 100%;">კლიენტი</th>
                            <th style="width: 100%;">ანგ. ფაქტურურა</th>
                            <th style="vertical-align: bottom !important; width: 20px; height: 140px;  padding-right:5px !important;"><span class="rotate style1" style="font-size:10pt !important;">საგარანტიო</span></th>                            
                            <th style="vertical-align: bottom !important; width: 20px; height: 140px;  padding-right:5px !important;"><span class="rotate style1" style="font-size:10pt !important;">ტონერი</span></th>
                            <th style="vertical-align: bottom !important; width: 20px; height: 140px;  padding-right:5px !important;"><span class="rotate style1" style="font-size:10pt !important;">ბარაბანი</span></th>
                            <th style="vertical-align: bottom !important; width: 20px; height: 140px;  padding-right:5px !important;"><span class="rotate style1" style="font-size:10pt !important;">მაგნიტური ლილვი</span></th>
                            <th style="vertical-align: bottom !important; width: 20px; height: 140px;  padding-right:5px !important;"><span class="rotate style1" style="font-size:10pt !important;">რეზინის ლილვი</span></th>
                            <th style="vertical-align: bottom !important; width: 20px; height: 140px;  padding-right:5px !important;"><span class="rotate style1" style="font-size:10pt !important;">გამწმ.რაკელი</span></th>
                            <th style="vertical-align: bottom !important; width: 20px; height: 140px;  padding-right:5px !important;"><span class="rotate style1" style="font-size:10pt !important;">დოზ.რაკელი</span></th>
                            <th style="vertical-align: bottom !important; width: 20px; height: 140px;  padding-right:5px !important;"><span class="rotate style1" style="font-size:10pt !important;">ჩიპი</span></th>
                            <th style="vertical-align: bottom !important; width: 20px; height: 140px;  padding-right:5px !important;"><span class="rotate style1" style="font-size:10pt !important;">კორპუსი</span></th>
                            <th style="vertical-align: bottom !important; width: 20px; height: 140px;  padding-right:5px !important;"><span class="rotate style1" style="font-size:10pt !important;">სერვისის გარეშე</span></th>
                            <th style="width: 60px; padding: 0px 0px 0px 0px; font-size: 8pt !important;">თანხა</th> 
                            <th style="width: 60px; padding: 0px 0px 0px 0px; font-size: 8pt !important;">თვით ღირებულება</th>
                            <th style="width: 60px; padding: 0px 0px 0px 0px; font-size: 8pt !important;">სხვაობა</th>                                                     
                        </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" id="search_type" name="search_type" value="ფილტრი" class="search_init" />
                            </th>  
                            <th>
                                <input type="text" id="search_code" name="search_code" value="ფილტრი" class="search_init" />
                            </th>                            
                            <th>
                               <input type="text" id="search_model" name="search_model" value="ფილტრი" class="search_init" />                              
                            </th>
                            <th>
                               <input type="text" id="search_letter" name="search_letter" value="ფილტრი" class="search_init" />
                            </th>     
                            <th>
                                <input type="text" id="search_date" name="search_date" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" id="search_client" name="search_client" value="ფილტრი" class="search_init" />
                            </th> 
                            <th>
                                <input type="text" id="search_client" name="search_client" value="ფილტრი" class="search_init" />
                            </th>                                                     
                            <th>
                            </th>                                                                        
                            <th>
                            </th> 
                            <th>
                            </th>    
                            <th>
                            </th> 
                            <th>
                            </th>                                                                        
                            <th>
                            </th> 
                            <th>
                            </th>    
                            <th>
                            </th>
                            <th>
                            </th>    
                            <th>
                            </th>
                            <th>
                            </th>                                                                                                                                                                 
                        </tr>
                    </thead>                       
                    <tfoot class="center_price">
                        <tr>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>  
                            <th>&nbsp;</th>                         
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th><p style="text-align:right !important; font-weight:bold !important;">ჯამი<br />სულ ჯამი</p></th>
                            <th id="sagarantio">&nbsp;</th>
                            <th id="toneri">&nbsp;</th>
                            <th id="barabani">&nbsp;</th>
                            <th id="magnituri">&nbsp;</th>
                            <th id="rezini">&nbsp;</th>
                            <th id="gamwmendi">&nbsp;</th>
                            <th id="dozirebis">&nbsp;</th>
                            <th id="chipi">&nbsp;</th>                                         
                            <th id="korpusi">&nbsp;</th>
                            <th id="">&nbsp;</th>     
                            <th id="price">&nbsp;</th> 
                            <th id="self_cost">&nbsp;</th>
                            <th id="">&nbsp;</th>                                                                            
                        </tr>
                    </tfoot>
                </table>
            </div>
            <div class="spacer">
            </div>
        </div>
    </div>
    <!-- jQuery Dialog -->
   <div id="dialog" class="form-dialog" title="ფასები"></div>
    
</body>
</html>